package com.chartHandle.config;

import com.chartHandle.bean.TemplateRemark;
import com.chartHandle.util.Util;
import com.projectCommon.excetion.ArgsConfigException;
import com.projectCommon.util.commonUtil.FileUtil;
import com.projectCommon.util.commonUtil.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * @author 吴宇~
 * @motto 我亦无他，唯手熟尔。
 * @edition jdk1.8
 * @reflection 0-1 喧闹任其喧闹，自由我自为之，我自风情万种，与世无争。
 * @date 2024/09/17/17:35
 * @target 心若有所向往，何惧道阻且长
 */
@Component
public class SmokeOrderTemplate1Config implements Verify {
    @Value("${wy.template.smokeOrder.path}")
    private String basePath;
    @Value("${wy.template.smokeOrder.t1.fileName}")
    private String fileName;
    @Value("${wy.template.smokeOrder.t1.widthOfColumn}")
    private String widthOfColumn;
    @Value("${wy.template.smokeOrder.t1.headHeight}")
    private String headHeight;
    @Value("${wy.template.smokeOrder.t1.imgColumnPosition}")
    private String imgColumnPosition;
    @Value("${wy.template.smokeOrder.t1.renderColorColumn}")
    private String renderColorColumnStr;
    @Value("${wy.template.smokeOrder.t1.lineColorS}")
    private String lineColorsStr;
    @Value("${wy.template.smokeOrder.t1.allotypeSmokeColor}")
    private String allotypeSmokeColorStr;
    @Value("${wy.template.smokeOrder.t1.remarkFileName}")
    private String remarkFilePath;
    @Value("${wy.template.smokeOrder.t1.listInterval}")
    private String listIntervalStr;
    @Value("${wy.template.smokeOrder.t1.baseRowHeight}")
    private String baseRowHeight;

    private byte[] fileByte;
    private int[] renderColorColumn;
    private int[] lineColorS;
    private short allotypeSmokeColor;
    private List<TemplateRemark> orderRemarks;
    private int[] listInterval;

    @PostConstruct
    public void init() {
        boolean b = verifyArgument();
        if (!b) {
            // TODO：并且中断系统。 让项目启动失败
            throw new ArgsConfigException();
        }
        //缓存到项目中
        this.fileByte = FileUtil.getResourceFileByte(basePath + fileName);
        this.renderColorColumn = StringUtils.conversionStrToArray(renderColorColumnStr);
        this.lineColorS = StringUtils.conversionStrToArray(lineColorsStr);
        this.allotypeSmokeColor = Short.parseShort(allotypeSmokeColorStr);
        this.orderRemarks = Util.getRemarks(remarkFilePath);
        this.listInterval = StringUtils.conversionStrToArray(listIntervalStr, ",");
    }

    public String getBasePath() {
        return basePath;
    }

    public String getFileName() {
        return fileName;
    }

    public String getWidthOfColumn() {
        return widthOfColumn;
    }

    public String getHeadHeight() {
        return headHeight;
    }

    public String getImgColumnPosition() {
        return imgColumnPosition;
    }

    public String getRenderColorColumnStr() {
        return renderColorColumnStr;
    }

    public String getLineColorsStr() {
        return lineColorsStr;
    }

    public byte[] getFileByte() {
        return fileByte;
    }

    public int[] getRenderColorColumn() {
        return renderColorColumn;
    }

    public int[] getLineColorS() {
        return lineColorS;
    }

    public short getAllotypeSmokeColor() {
        return allotypeSmokeColor;
    }

    public List<TemplateRemark> getOrderRemarks() {
        return orderRemarks;
    }

    public int[] getListInterval() {
        return listInterval;
    }

    public String getBaseRowHeight() {
        return baseRowHeight;
    }

    @Override
    public boolean verifyArgument() {
        return true;
    }
}
